// pages/details/details.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
       imgUrl:[],//曲谱地址
       title: "",//曲谱标题
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
       var imgarry = this.data.imgUrl
       imgarry.push(options.imgUrl)
       this.setData({
            title: options.title,
            imgUrl: imgarry
       })
       //页面标题为路由参数
       wx.setNavigationBarTitle({
            title: options.title
       })
  },
  //   图片预览
  previewImg: function (event) {
       var that = this;
       var index = event.currentTarget.dataset.index;//获取点击图片的index
       var imgs = event.currentTarget.dataset.imgs;//获取图片的地址
       wx.previewImage({
            current: imgs,
            urls: imgs,
       })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
       var that=this
       var title = that.data.title
       var imgUrl = that.data.imgUrl
       if (res.from === 'button') {
            // 来自页面内转发按钮
            //console.log(res.target)
       }
       return {
            title: title ,
            path: '/pages/details/details?imgUrl='+imgUrl,
            success: function (res) {
                 wx.showToast({
                      title: '发送成功',
                      icon: 'none'
                 })
            },
            fail: function (res) {
                 // 转发失败
                 wx.showToast({
                      title: '发送失败',
                      icon: 'none'
                 })
            }
       }
  }
})